package com.mallcloud.mall.admin.mapper;

import com.mallcloud.mall.admin.api.entity.SysRegion;
import com.mallcloud.mall.common.data.datascope.MallBaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 全国省市区
 */
@Mapper
public interface SysRegionMapper extends MallBaseMapper<SysRegion> {

	@Select("SELECT * FROM sys_region WHERE parent_id = (SELECT id FROM sys_region WHERE region_code = #{code}) AND level_id = 2")
	List<SysRegion> getCity(@Param("code") Long code);

	@Select("SELECT * FROM sys_region WHERE parent_id = (SELECT id FROM sys_region WHERE region_code = #{code}) AND level_id = 3")
	List<SysRegion> getArea(@Param("code") Long code);
}
